package com.joker.cart.controller;

import com.joker.cart.service.CartService;
import com.joker.cart.vo.CartRequest;
import com.joker.cart.vo.CartVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/cartItem")
public class CartController {
    @Resource
    private CartService cartService;

    /**
     * 添加购物车
     * @return
     */
    @PostMapping("/add")
    public void addCart(@RequestBody CartRequest cartRequest){
         cartService.addCartItem(cartRequest);
    }
    /**
     * 删除购物车
     */
    @GetMapping("deleteCartItem/{skuIds}")
    public void deleteCartItem(@PathVariable String skuIds){
        cartService.deleteCartItem(skuIds);
    }

    /**
     * 购物车列表
     */
    @GetMapping("/cartVoList")
    public List<CartVo> cartVoList(){
        return cartService.cartVoList();
    }
}
